package com.rain.shoppingscienceproj.ui.utile;

import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.rain.shoppingscienceproj.R;


/**
 * Author: Rain
 * Create: 2017/12/11 16:48
 */

public class TitleUtils {

    public static TextView mTitle, mRightText;
    public static RelativeLayout mBask, mRight;
    public static ImageView mRightImage;

    /**
     * 标准标题
     *
     * @param activity
     * @param title
     */
    public static void TitleView(AppCompatActivity activity, String title) {
        mBask = (RelativeLayout) activity.findViewById(R.id.rl_back);
        mTitle = (TextView) activity.findViewById(R.id.tv_title);
        mRight = (RelativeLayout) activity.findViewById(R.id.rl_right);
        mBask.setOnClickListener(v -> activity.finish());
        mTitle.setText(title);
    }

    /**
     * 右边文字
     *
     * @param activity
     * @param title
     * @param rightText
     */
    public static void TitleRightText(AppCompatActivity activity, String title, String rightText) {
        mBask = (RelativeLayout) activity.findViewById(R.id.rl_back);
        mTitle = (TextView) activity.findViewById(R.id.tv_title);
        mRight = (RelativeLayout) activity.findViewById(R.id.rl_right);
        mRightImage = (ImageView) activity.findViewById(R.id.iv_right_image);
        mRightText = (TextView) activity.findViewById(R.id.right_text);
        mRight.setVisibility(View.VISIBLE);
        mRightText.setVisibility(View.VISIBLE);
        mRightImage.setVisibility(View.GONE);
        mRightText.setText(rightText);
        mBask.setOnClickListener(v -> activity.finish());
        mTitle.setText(title);
    }

    /**
     * 右边图片
     *
     * @param activity
     * @param title
     * @param rightImage
     */
    public static void TitleRightImage(AppCompatActivity activity, String title, int rightImage) {
        mBask = (RelativeLayout) activity.findViewById(R.id.rl_back);
        mTitle = (TextView) activity.findViewById(R.id.tv_title);
        mRight = (RelativeLayout) activity.findViewById(R.id.rl_right);
        mRightImage = (ImageView) activity.findViewById(R.id.iv_right_image);
        mRightText = (TextView) activity.findViewById(R.id.right_text);
        mRight.setVisibility(View.VISIBLE);
        mRightText.setVisibility(View.GONE);
        mRightImage.setVisibility(View.VISIBLE);
        mRightImage.setImageResource(rightImage);
        mBask.setOnClickListener(v -> activity.finish());
        mTitle.setText(title);
    }
}
